<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>选项卡</title>
    <script src="js/vue.global.js"></script>
    <style>
        #optoncard .titlebar span{
            height: 32px;
            width: 100px;
            display: block; /* 设置当前元素显示模式：块级元素 */
            text-align: center;
            line-height: 32px;
            text-decoration: none; /* 去掉下划线 */
            background-color: #afafaf;
            color: #000;
            float: left;
            margin: 4px;
        }
        #optoncard .titlebar:after{
            /* 去除浮动 */
            clear: both;
            display: block;
            content: "";
        }

        #optoncard .contentbox .content{
            width: 500px;
            height: 350px;
            background-color: yellow;
            display: none;
        }

        #optoncard .contentbox .active{
            display: block;
        }

        #optoncard .titlebar .current{
            background-color: yellow;
        }
    </style>
</head>
<body>
<div id="optoncard">
    <div class="titlebar">
        <span :class="{current:current_title==0}" @click="current_title=0">体育新闻</span>
        <span :class="{current:current_title==1}" @click="current_title=1">财经资讯</span>
        <span :class="{current:current_title==2}" @click="current_title=2">娱乐</span>
    </div>
    <div class="contentbox">
        <div :class="{content:true,active: current_title==0}">
            体育新闻
        </div>
        <div :class="{content:true,active: current_title==1}">
            财经资讯
        </div>
        <div :class="{content:true,active: current_title==2}">
            娱乐
        </div>
    </div>
</div>
<script>
    var oc_vm = Vue.createApp({
        data(){
            return{
                current_title: 0
            }
        }
    }).mount("#optoncard")
</script>
</body>
</html>